home *** CD-ROM | disk | FTP | other *** search
/ Gamers Delight 2 / Gamers Delight 2.iso / Aminet / game / role / larn.lha / display.c < prev    next >
C/C++ Source or Header  |  1995-11-19  |  21KB  |  707 lines

  1. /* display.c */
  2. #include "header.h"
  3. #include "larndefs.h"
  4. #include "objects.h"
  5. #include "player.h"
  6.  
  7. #define botsub( _idx, _x, _y, _str )        \
  8.     if ( c[(_idx)] != cbak[(_idx)] )        \
  9.     {                                   \
  10.     cbak[(_idx)] = c[(_idx)];           \
  11.     cursor( (_x), (_y) );               \
  12.     lprintf( (_str), (long)c[(_idx)] ); \
  13.     }
  14.  
  15. static int  minx,maxx,miny,maxy,k;
  16. static char bot1f=0,bot2f=0,bot3f=0;
  17. static char always=0;
  18.        char regen_bottom = 0;
  19.  
  20. /*
  21.     bottomline()
  22.  
  23.     now for the bottom line of the display
  24.  */
  25. bottomline()
  26.     {   recalc();   bot1f=1;    }
  27. bottomhp()
  28.     {   bot2f=1;    }
  29. bottomspell()
  30.     {   bot3f=1;    }
  31. bottomdo()
  32.     {
  33.     if (bot1f) { bot3f=bot1f=bot2f=0; bot_linex(); return; }
  34.     if (bot2f) { bot2f=0; bot_hpx(); }
  35.     if (bot3f) { bot3f=0; bot_spellx(); }
  36.     }
  37.  
  38. bot_linex()
  39.     {
  40.     register int i;
  41.     if ( regen_bottom || (always))
  42.         {
  43.         regen_bottom = FALSE ;
  44.         cursor( 1,18);
  45.         if (c[SPELLMAX]>99)  lprintf("Spells:%3d(%3d)",(long)c[SPELLS],(long)c[SPELLMAX]);
  46.                         else lprintf("Spells:%3d(%2d) ",(long)c[SPELLS],(long)c[SPELLMAX]);
  47.         lprintf(" AC: %-3d  WC: %-3d  Level",(long)c[AC],(long)c[WCLASS]);
  48.         if (c[LEVEL]>99) lprintf("%3d",(long)c[LEVEL]);
  49.                     else lprintf(" %-2d",(long)c[LEVEL]);
  50.         lprintf(" Exp: %-9d %s\n",(long)c[EXPERIENCE],class[c[LEVEL]-1]);
  51.         lprintf("HP: %3d(%3d) STR=%-2d INT=%-2d ",
  52.             (long)c[HP],(long)c[HPMAX],(long)(c[STRENGTH]+c[STREXTRA]),(long)c[INTELLIGENCE]);
  53.         lprintf("WIS=%-2d CON=%-2d DEX=%-2d CHA=%-2d LV:",
  54.             (long)c[WISDOM],(long)c[CONSTITUTION],(long)c[DEXTERITY],(long)c[CHARISMA]);
  55.  
  56.         if ((level==0) || (wizard))  c[TELEFLAG]=0;
  57.         if (c[TELEFLAG])  lprcat(" ?");  else  lprcat(levelname[level]);
  58.         lprintf("  Gold: %-6d",(long)c[GOLD]);
  59.         always=1;  botside();
  60.         c[TMP] = c[STRENGTH]+c[STREXTRA];
  61.         for (i=0; i<100; i++) cbak[i]=c[i];
  62.         return;
  63.         }
  64.  
  65.     botsub(SPELLS,8,18,"%3d");
  66.     if (c[SPELLMAX]>99)
  67.         {
  68.         botsub(SPELLMAX,12,18,"%3d)");
  69.         }
  70.     else
  71.         botsub(SPELLMAX,12,18,"%2d) ");
  72.     botsub(HP,5,19,"%3d");
  73.     botsub(HPMAX,9,19,"%3d");
  74.     botsub(AC,21,18,"%-3d");
  75.     botsub(WCLASS,30,18,"%-3d");
  76.     botsub(EXPERIENCE,49,18,"%-9d");
  77.     if (c[LEVEL] != cbak[LEVEL])
  78.         {
  79.         cursor(59,18);
  80.         lprcat(class[c[LEVEL]-1]);
  81.         }
  82.     if (c[LEVEL]>99)
  83.         {
  84.         botsub(LEVEL,40,18,"%3d");
  85.         }
  86.     else
  87.         botsub(LEVEL,40,18," %-2d");
  88.     c[TMP] = c[STRENGTH]+c[STREXTRA];
  89.     botsub(TMP,18,19,"%-2d");
  90.     botsub(INTELLIGENCE,25,19,"%-2d");
  91.     botsub(WISDOM,32,19,"%-2d");
  92.     botsub(CONSTITUTION,39,19,"%-2d");
  93.     botsub(DEXTERITY,46,19,"%-2d");
  94.     botsub(CHARISMA,53,19,"%-2d");
  95.     if ((level != cbak[CAVELEVEL]) || (c[TELEFLAG] != cbak[TELEFLAG]))
  96.         {
  97.         if ((level==0) || (wizard))
  98.             c[TELEFLAG]=0;
  99.         cbak[TELEFLAG] = c[TELEFLAG];
  100.         cbak[CAVELEVEL] = level;
  101.         cursor(59,19);
  102.         if (c[TELEFLAG])
  103.             lprcat(" ?");
  104.         else
  105.             lprcat(levelname[level]);
  106.         }
  107.     botsub(GOLD,69,19,"%-6d");
  108.     botside();
  109.     }
  110.  
  111. /*
  112.     special subroutine to update only the gold number on the bottomlines
  113.     called from ogold()
  114.  */
  115. bottomgold()
  116.     {
  117.     botsub(GOLD,69,19,"%-6d");
  118.     }
  119.  
  120. /*
  121.     special routine to update hp and level fields on bottom lines
  122.     called in monster.c hitplayer() and spattack()
  123.  */
  124. static bot_hpx()
  125.     {
  126.     if (c[EXPERIENCE] != cbak[EXPERIENCE])
  127.         {
  128.         recalc();
  129.         bot_linex();
  130.         }
  131.     else
  132.         botsub(HP,5,19,"%3d");
  133.     }
  134.  
  135. /*
  136.     special routine to update number of spells called from regen()
  137.  */
  138. static bot_spellx()
  139.     {
  140.     botsub(SPELLS,9,18,"%2d");
  141.     }
  142.  
  143. /*
  144.     common subroutine for a more economical bottomline()
  145.  */
  146. static struct bot_side_def
  147.     {
  148.     int typ;
  149.     char *string;
  150.     }
  151.     bot_data[] =
  152.     {
  153.     STEALTH,"stealth",      UNDEADPRO,"undead pro",     SPIRITPRO,"spirit pro",
  154.     CHARMCOUNT,"Charm",     TIMESTOP,"Time Stop",       HOLDMONST,"Hold Monst",
  155.     GIANTSTR,"Giant Str",   FIRERESISTANCE,"Fire Resit", DEXCOUNT,"Dexterity",
  156.     STRCOUNT,"Strength",    SCAREMONST,"Scare",         HASTESELF,"Haste Self",
  157.     CANCELLATION,"Cancel",  INVISIBILITY,"Invisible",   ALTPRO,"Protect 3",
  158.     PROTECTIONTIME,"Protect 2", WTW,"Wall-Walk"
  159.     };
  160.  
  161. static botside()
  162.     {
  163.     register int i,idx;
  164.     for (i=0; i<17; i++)
  165.         {
  166.         idx = bot_data[i].typ;
  167.         if ((always) || (c[idx] != cbak[idx]))
  168.            {
  169.            if ((always) || (cbak[idx] == 0))
  170.                 { if (c[idx]) { cursor(70,i+1); lprcat(bot_data[i].string); } }  else
  171.            if (c[idx]==0)     { cursor(70,i+1); lprcat("          "); }
  172.            cbak[idx]=c[idx];
  173.            }
  174.         }
  175.     always=0;
  176.     }
  177.  
  178. /*
  179.  *  subroutine to draw only a section of the screen
  180.  *  only the top section of the screen is updated.  If entire lines are being
  181.  *  drawn, then they will be cleared first.
  182.  */
  183. static int d_xmin=0,d_xmax=MAXX,d_ymin=0,d_ymax=MAXY;  /* for limited screen drawing */
  184. draws(xmin,xmax,ymin,ymax)
  185.     int xmin,xmax,ymin,ymax;
  186.     {
  187.     register int i,idx;
  188.     if (xmin==0 && xmax==MAXX) /* clear section of screen as needed */
  189.         {
  190.         if (ymin==0) cl_up(79,ymax);
  191.         else for (i=ymin; i<ymin; i++)  cl_line(1,i+1);
  192.         xmin = -1;
  193.         }
  194.     d_xmin=xmin;    d_xmax=xmax;    d_ymin=ymin;    d_ymax=ymax;    /* for limited screen drawing */
  195.     drawscreen();
  196.     if (xmin<=0 && xmax==MAXX) /* draw stuff on right side of screen as needed*/
  197.         {
  198.         for (i=ymin; i<ymax; i++)
  199.             {
  200.             idx = bot_data[i].typ;
  201.             if (c[idx])
  202.                 {
  203.                 cursor(70,i+1); lprcat(bot_data[i].string);
  204.                 }
  205.             cbak[idx]=c[idx];
  206.             }
  207.         }
  208.     }
  209.  
  210. #ifdef DECRainbow
  211.  static int DECgraphics;     /* The graphics mode toggle */
  212.  
  213. # define DECgraphicsON() if (!DECgraphics) lprc('\16'), DECgraphics = 1
  214. # define DECgraphicsOFF() if (DECgraphics) lprc('\17'), DECgraphics = 0
  215.  
  216. /* For debugging on a non-DEC
  217. # define DECgraphicsON() if (!DECgraphics) lprcat("\33[4m"), DECgraphics = 1
  218. # define DECgraphicsOFF() if (DECgraphics) lprcat("\33[0m"), DECgraphics = 0
  219. */
  220.  
  221. # define DEClprc(ch)    if (ch & 0x80) {\
  222.                             DECgraphicsON();\
  223.                             lprc(ch ^ 0x80);\
  224.                         } else {\
  225.                             DECgraphicsOFF();\
  226.                             lprc(ch);\
  227.                         }
  228. #define nlprc(_ch) DEClprc(_ch)
  229. # else
  230. #define nlprc(_ch) lprc(_ch)
  231. #endif DECRainbow
  232.  
  233. /*
  234.     drawscreen()
  235.  
  236.     subroutine to redraw the whole screen as the player knows it
  237.  */
  238. static char d_flag;
  239. drawscreen()
  240.     {
  241.     register int i,j,k,ileft,iright;
  242.  
  243.     if (d_xmin==0 && d_xmax==MAXX && d_ymin==0 && d_ymax==MAXY)
  244.         {
  245.         d_flag=1;  clear(); /* clear the screen */
  246.         }
  247.     else
  248.         {
  249.         d_flag=0;  cursor(1,1);
  250.         }
  251.     if (d_xmin<0)
  252.         d_xmin=0; /* d_xmin=-1 means display all without bottomline */
  253.  
  254.     /* display lines of the screen
  255.     */
  256.     for ( j = d_ymin ; j < d_ymax ; j++ )
  257.         {
  258.         /* When we show a spot of the dungeon, we have 4 cases:
  259.             squares we know nothing about
  260.                 - know == 0
  261.             squares we've been at and still know whats there
  262.                 - know == KNOWALL (== KNOWHERE | HAVESEEN)
  263.             squares we've been at, but don't still recall because
  264.             something else happened there.
  265.                 - know == HAVESEEN
  266.             squares we recall, but haven't been at (an error condition)
  267.                 - know == KNOWHERE
  268.  
  269.            to minimize printing of spaces, scan from left of line until
  270.            we reach a location that the user knows.
  271.         */
  272.         ileft = d_xmin - 1;
  273.         while ( ++ileft < d_xmax )
  274.             if (know[ileft][j])     /* instead of know[i][j] != 0 */
  275.                 break;              /* exitloop while */
  276.  
  277.         /* if not a blank line ... */
  278.         if ( ileft < d_xmax )
  279.             {
  280.             /* scan from right of line until we reach a location that the
  281.                user knows.
  282.             */
  283.             iright = d_xmax ;
  284.             while ( --iright > ileft )
  285.                 if (know[iright][j])
  286.                     break ;    /* exitloop while */
  287.  
  288.             /* now print the line, after positioning the cursor.
  289.                print the line with bold objects in a different
  290.                loop for effeciency
  291.             */
  292.             cursor( ileft+1, j+1 );
  293.             if (boldobjects)
  294.                 for ( i=ileft ; i <= iright ; i++ )
  295.  
  296.                     /* we still need to check for the location being known,
  297.                        for we might have an unknown spot in the middle of
  298.                        an otherwise known line.
  299.                     */
  300.                     if ( know[i][j] == 0 )
  301.                         nlprc( ' ' );
  302.                     else if ( know[i][j] & HAVESEEN )
  303.                         {
  304.                         /* if monster there and the user still knows the place,
  305.                            then show the monster.  Otherwise, show what was
  306.                            there before.
  307.                         */
  308.                         if (( i == playerx ) &&
  309.                             ( j == playery ))
  310.                             nlprc('@');
  311.                         else if (( k = mitem[i][j] ) &&
  312.                             ( know[i][j] & KNOWHERE ))
  313.                             nlprc( monstnamelist[k] );
  314.                         else if (((k=item[i][j]) == OWALL ) ||
  315.                                  (objnamelist[k] == floorc))
  316.                             nlprc( objnamelist[k] );
  317.                         else
  318.                             {
  319.                             setbold();
  320.                             nlprc( objnamelist[k] );
  321.                             resetbold();
  322.                             }
  323.                         }
  324.                     else
  325.                         /* error condition.  recover by resetting location
  326.                            to an 'unknown' state.
  327.                         */
  328.                         {
  329.                         nlprc( ' ' );
  330.                         mitem[i][j] = item[i][j] = 0 ;
  331.                         }
  332.             else /* non-bold objects here */
  333.                 for ( i=ileft ; i <= iright ; i++ )
  334.  
  335.                     /* we still need to check for the location being known,
  336.                        for we might have an unknown spot in the middle of
  337.                        an otherwise known line.
  338.                     */
  339.                     if ( know[i][j] == 0 )
  340.                         nlprc( ' ' );
  341.                     else if ( know[i][j] & HAVESEEN )
  342.                         {
  343.                         /* if monster there and the user still knows the place,
  344.                            then show the monster.  Otherwise, show what was
  345.                            there before.
  346.                         */
  347.                         if (( i == playerx ) &&
  348.                             ( j == playery ))
  349.                             nlprc('@');
  350.                         else if (( k = mitem[i][j] ) &&
  351.                             ( know[i][j] & KNOWHERE ))
  352.                             nlprc( monstnamelist[k] );
  353.                         else
  354.                             nlprc( objnamelist[item[i][j]] );
  355.                         }
  356.                     else
  357.                         /* error condition.  recover by resetting location
  358.                            to an 'unknown' state.
  359.                         */
  360.                         {
  361.                         nlprc( ' ' );
  362.                         mitem[i][j] = item[i][j] = 0 ;
  363.                         }
  364.             }   /* if (ileft < d_xmax ) */
  365.         }       /* for (j) */
  366.  
  367. #ifdef DECRainbow
  368.     if (DECRainbow)
  369.         DECgraphicsOFF();
  370. #endif DECRainbow
  371.     resetbold();
  372.     if (d_flag)  { always=1; botside(); always=1; bot_linex(); }
  373. /*
  374.     oldx=99;
  375. */
  376.     d_xmin = d_ymin = 0; d_xmax = MAXX; d_ymax = MAXY; /* for limited screen drawing */
  377.     }
  378.  
  379. /*
  380.     showcell(x,y)
  381.  
  382.     subroutine to display a cell location on the screen
  383.  */
  384. showcell(x,y)
  385.     int x,y;
  386.     {
  387.     register int i,j,k,m;
  388.     if (c[BLINDCOUNT])  return; /* see nothing if blind     */
  389.     if (c[AWARENESS]) { minx = x-3; maxx = x+3; miny = y-3; maxy = y+3; }
  390.             else      { minx = x-1; maxx = x+1; miny = y-1; maxy = y+1; }
  391.  
  392.     if (minx < 0) minx=0;       if (maxx > MAXX-1) maxx = MAXX-1;
  393.     if (miny < 0) miny=0;       if (maxy > MAXY-1) maxy = MAXY-1;
  394.  
  395.     for (j=miny; j<=maxy; j++)
  396.       for (m=minx; m<=maxx; m++)
  397.         if ((know[m][j] & KNOWHERE) == 0)
  398.             {
  399.             cursor(m+1,j+1);
  400.         x=maxx;
  401.         while (know[x][j] & KNOWHERE)
  402.         --x;
  403.             for (i=m; i<=x; i++)
  404.                 {
  405.                 if ((k=mitem[i][j]) != 0)  lprc(monstnamelist[k]);
  406.                 else switch(k=item[i][j])
  407.                     {
  408.                     case OWALL:  case 0: case OIVTELETRAP:  case OTRAPARROWIV:
  409.                     case OIVDARTRAP: case OIVTRAPDOOR:
  410. #ifdef DECRainbow
  411.                         if (DECRainbow) {
  412.                             DEClprc(objnamelist[k]);
  413.                         } else
  414. #endif DECRainbow
  415.                         lprc(objnamelist[k]);   
  416.                         break;
  417.                     default:
  418.                         if (boldobjects)
  419.                             setbold();
  420.                         lprc(objnamelist[k]);
  421.                         if (boldobjects)
  422.                             resetbold();
  423.                         break;
  424.                     };
  425.                 know[i][j] = KNOWALL;
  426.                 }
  427.             m = maxx;
  428. #ifdef DECRainbow
  429.             if (DECRainbow)
  430.                 DECgraphicsOFF();
  431. #endif DECRainbow
  432.             }
  433.     }
  434.  
  435. /*
  436.     this routine shows only the spot that is given it.  the spaces around
  437.     these coordinated are not shown
  438.     used in godirect() in monster.c for missile weapons display
  439.  */
  440. show1cell(x,y)
  441.     int x,y;
  442.     {
  443.     cursor(x+1,y+1);
  444.  
  445.     /* see nothing if blind, but clear previous player position
  446.     */
  447.     if (c[BLINDCOUNT])
  448.         {
  449.         if ((x == oldx) && (y == oldy))
  450.             lprc(' ');
  451.         return;
  452.         }
  453.  
  454.     if ((k=mitem[x][y]))
  455.         lprc(monstnamelist[k]);
  456.     else switch(k=item[x][y])
  457.         {
  458.         case OWALL:  case 0:  case OIVTELETRAP:  case OTRAPARROWIV:
  459.         case OIVDARTRAP: case OIVTRAPDOOR:
  460. # ifdef DECRainbow
  461.             if (DECRainbow) {
  462.                 DEClprc(objnamelist[k]);
  463.                 DECgraphicsOFF();
  464.             } else
  465. # endif
  466.                 lprc(objnamelist[k]);
  467.                 break;
  468.  
  469.         default:
  470.             if (boldobjects)
  471.                 setbold();
  472.             lprc(objnamelist[k]);
  473.             if (boldobjects)
  474.                 resetbold();
  475.             break;
  476.         };
  477.     know[x][y] = KNOWALL;   /* we end up knowing about it */
  478.     }
  479.  
  480. /*
  481.     showplayer()
  482.  
  483.     subroutine to show where the player is on the screen
  484.     cursor values start from 1 up
  485.  */
  486. showplayer()
  487.     {
  488.     show1cell( oldx, oldy );
  489.     cursor(playerx+1,playery+1);
  490.     lprc('@');
  491.     cursor(playerx+1,playery+1);
  492.     oldx=playerx;  oldy=playery;
  493.     }
  494.  
  495. /*
  496.     moveplayer(dir)
  497.  
  498.     subroutine to move the player from one room to another
  499.     returns 0 if can't move in that direction or hit a monster or on an object
  500.     else returns 1
  501.     nomove is set to 1 to stop the next move (inadvertent monsters hitting
  502.     players when walking into walls) if player walks off screen or into wall
  503.  */
  504. short diroffx[] = { 0,  0, 1,  0, -1,  1, -1, 1, -1 };
  505. short diroffy[] = { 0,  1, 0, -1,  0, -1, -1, 1,  1 };
  506. moveplayer(dir)
  507.     int dir;            /*  from = present room #  direction = [1-north]
  508.                             [2-east] [3-south] [4-west] [5-northeast]
  509.                             [6-northwest] [7-southeast] [8-southwest]
  510.                         if direction=0, don't move--just show where he is */
  511.     {
  512.     register int k,m,i,j;
  513.     extern char prayed ;
  514.  
  515.     if (c[CONFUSE]) if (c[LEVEL]<rnd(30)) dir=rund(9); /*if confused any dir*/
  516.     k = playerx + diroffx[dir];     m = playery + diroffy[dir];
  517.     if (k<0 || k>=MAXX || m<0 || m>=MAXY) { nomove=1; return(yrepcount = 0); }
  518.     i = item[k][m];         j = mitem[k][m];
  519.  
  520.     /* prevent the player from moving onto a wall, or a closed door when
  521.        in command mode, unless the character has Walk-Through-Walls.
  522.     */
  523.     if ((i==OCLOSEDDOOR && !prompt_mode) || (i==OWALL) && c[WTW]==0)
  524.         { 
  525.         nomove=1;  
  526.         return(yrepcount = 0); 
  527.         }
  528.     if (k==33 && m==MAXY-1 && level==1)
  529.         {
  530.         newcavelevel(0); 
  531.         for (k=0; k<MAXX; k++) 
  532.             for (m=0; m<MAXY; m++)
  533.                 if (item[k][m]==OENTRANCE)
  534.                     { 
  535.                     playerx=k; 
  536.                     playery=m; 
  537.                     positionplayer();  
  538.                     drawscreen(); 
  539.                     return(0); 
  540.                     }
  541.         }
  542.     /* hit a monster
  543.     */    
  544.     if (j>0)     
  545.         { hitmonster(k,m); return(yrepcount = 0); } 
  546.  
  547.     /* check for the player ignoring an altar when in command mode.
  548.     */
  549.     if ((!prompt_mode) &&
  550.         (item[playerx][playery] == OALTAR) &&
  551.         (!prayed))
  552.         {
  553.     cursors();
  554.     lprcat("\nYou have ignored the altar!");
  555.     act_ignore_altar();
  556.     }
  557.     prayed = 0 ;
  558.  
  559.     lastpx = playerx;   lastpy = playery;
  560.     playerx = k;        playery = m;
  561.     if (i && i!=OTRAPARROWIV && i!=OIVTELETRAP && i!=OIVDARTRAP && i!=OIVTRAPDOOR) 
  562.         return(yrepcount = 0);  
  563.     else 
  564.         return(1);
  565.     }
  566.  
  567. /*
  568.  *  function to show what magic items have been discovered thus far
  569.  *  enter with -1 for just spells, anything else will give scrolls & potions
  570.  */
  571. static int lincount,count;
  572. seemagic(arg)
  573.     int arg;
  574.     {
  575.     register int i,j,k,number;
  576.     char sort[SPNUM+1]; /* OK as long as SPNUM > MAXSCROLL,MAXPOTION */
  577.  
  578.     count = lincount = 0;
  579.     nosignal=1;
  580.  
  581.     /* count and sort the known spell codes
  582.     */
  583.     for (j=0; j <= SPNUM ; j++ )
  584.         sort[j] = SPNUM ;
  585.     for (number = i = 0 ; i < SPNUM ; i++ )
  586.         if (spelknow[i])
  587.             {
  588.             number++;
  589.             j = 0 ;
  590.             while ( strncmp( spelcode[ sort[j] ], spelcode[ i ], 3 ) < 0 )
  591.                 j++ ;
  592.             k = number - 1;
  593.             while ( k > j )
  594.                 sort[k] = sort[ k-1 ], k-- ;
  595.             sort[j] = i ;
  596.             }
  597.  
  598.     if (arg == -1) /* if display spells while casting one */
  599.         {
  600.         cl_up(79, ((number + 2) / 3 + 4 )); /* lines needed for display */
  601.         cursor(1,1);
  602.         }
  603.     else
  604.         {
  605.         resetscroll();
  606.         clear();
  607.         }
  608.  
  609.     lprcat("The magic spells you have discovered thus far:\n\n");
  610.     for (i=0; i<number; i++)
  611.         {
  612.         lprintf("%s %-20s ",spelcode[sort[i]],spelname[sort[i]]);
  613.         seepage();
  614.         }
  615.  
  616.     if (arg== -1)
  617.         {
  618.         seepage();
  619.         more(FALSE);
  620.         nosignal=0;
  621.         draws(0,MAXX,0, (( number + 2 ) / 3 + 4 ));
  622.         return;
  623.         }
  624.  
  625.     lincount += 3;
  626.     if (count!=0)
  627.         {
  628.         count=2;
  629.         seepage();
  630.         }
  631.  
  632.     /* count and sort the known scrolls
  633.     */
  634.     for (j=0; j <= MAXSCROLL ; j++ )
  635.         sort[j] = MAXSCROLL ;
  636.     for (number = i = 0 ; i < MAXSCROLL ; i++ )
  637.         if (scrollname[i][0])
  638.             {
  639.             number++;
  640.             j = 0 ;
  641.             while ( strcmp( &scrollname[sort[j]][1], &scrollname[i][1] ) < 0 )
  642.                 j++ ;
  643.             k = number - 1;
  644.             while ( k > j )
  645.                 sort[k] = sort[ k-1 ], k-- ;
  646.             sort[j] = i ;
  647.             }
  648.  
  649.     lprcat("\nThe magic scrolls you have found to date are:\n\n");
  650.     count=0;
  651.     for (i=0; i < number; i++ )
  652.         {
  653.         lprintf("%-26s", &scrollname[sort[i]][1]);
  654.         seepage();
  655.         }
  656.  
  657.     lincount += 3;
  658.     if ( count != 0 )
  659.         {
  660.         count=2;
  661.         seepage();
  662.         }
  663.  
  664.     /* count and sort the known potions
  665.     */
  666.     for (j=0; j <= MAXPOTION ; j++ )
  667.         sort[j] = MAXPOTION ;
  668.     for (number = i = 0 ; i < MAXPOTION ; i++ )
  669.         if (potionname[i][0])
  670.             {
  671.             number++;
  672.             j = 0 ;
  673.             while ( strcmp( &potionname[sort[j]][1], &potionname[i][1] ) < 0 )
  674.                 j++ ;
  675.             k = number - 1;
  676.             while ( k > j )
  677.                 sort[k] = sort[ k-1 ], k-- ;
  678.             sort[j] = i ;
  679.             }
  680.  
  681.     lprcat("\nThe magic potions you have found to date are:\n\n");
  682.     count=0;
  683.     for (i=0; i < number; i++)
  684.         {
  685.         lprintf("%-26s",&potionname[sort[i]][1]);
  686.         seepage();
  687.         }
  688.  
  689.     if (lincount!=0)
  690.         more(FALSE);
  691.     nosignal=0;
  692.     setscroll();
  693.     drawscreen();
  694.     }
  695.  
  696. /*
  697.  *  subroutine to paginate the seemagic function
  698.  */
  699. static seepage()
  700.     {
  701.     if (++count==3)
  702.         {
  703.         lincount++; count=0;    lprc('\n');
  704.         if (lincount>17) {  lincount=0;  more(FALSE);  clear();  }
  705.         }
  706.     }
  707.